package spynx.util;


public class ArrayCharSequence implements CharSequence {

	byte buffer[];
	
	public ArrayCharSequence(byte buffer[]) {
		this.buffer = buffer;
	}
	
	@Override
	public int length() {
		return buffer.length;
	}

	@Override
	public char charAt(int index) {
		char ch = (char)buffer[index];
		return ch;
	}

	@Override
	public CharSequence subSequence(int start, int end) {
		byte sub[] = new byte[end - start];
		System.arraycopy(buffer, start, sub, 0, sub.length);
		return new ArrayCharSequence(sub);
	}

	@Override
	public String toString() {
		return new StringBuffer(this).toString();
	}
}
